export function validateChatMessage(payload: any) {
  if (!payload || typeof payload !== 'object') throw new Error('Invalid payload');
  const { roomId, userId, message } = payload;
  if (typeof roomId !== 'string' || typeof userId !== 'string' || typeof message !== 'string') {
    throw new Error('Invalid chat message fields');
  }
  return {
    ...payload,
    timestamp: payload.timestamp || Date.now()
  };
}
